package 容器.main.java.com.itheima;

import com.itheima.dao.BookDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 获取bean对象的三种方式
 */
public class getBeanMethods {
    public static void main(String[] args) {
        ApplicationContext ioc=new ClassPathXmlApplicationContext("applicationContext.xml");
        //1.根据名称获取bean
        BookDao bookDao = (BookDao) ioc.getBean("bookDao");
        //2.根据名称获取bean，并指定了类型,这样拿到的bean就是指定的类型
        BookDao bookDao1 = ioc.getBean("bookDao", BookDao.class);
        //使用bean类型获取,这要求ioc容器里面的bean唯一
        BookDao bean = ioc.getBean(BookDao.class);
    }
}
